Skip to content

[test](regression) Add malformed percent-encoding test cases for url_decode#64645

Open
yifanwu-sys wants to merge 1 commit into
apache:masterfrom
yifanwu-sys:add-regression-test-url-decode-clean
Open

[test](regression) Add malformed percent-encoding test cases for url_decode#64645
yifanwu-sys wants to merge 1 commit into
apache:masterfrom
yifanwu-sys:add-regression-test-url-decode-clean

Conversation

@yifanwu-sys

Copy link
Copy Markdown

What problem does this PR solve?

The url_decode regression test mainly covers valid URL decoding cases, but malformed percent-encoding inputs are not explicitly covered.

Malformed inputs such as truncated percent sequences or invalid hex characters should return an error. Without regression coverage, this behavior may be changed accidentally in future updates.

What is changed?

This PR adds regression test cases for malformed percent-encoding inputs in test_url_decode.groovy, including:

  • truncated percent sequence: '%2'
  • bare percent sign: '%'
  • trailing percent sign: 'hello%'
  • invalid hex characters: '%GG'
  • mixed valid and invalid encoding: '%20%GG%41'
  • consecutive percent signs: '%%20'

Each case verifies that url_decode raises the expected error:

Decode url failed

Behavior change

No behavior is changed.

This PR only adds regression test coverage for the existing error behavior of url_decode.

Impact

Test-only change. It does not affect build behavior, runtime behavior, SQL execution logic, storage behavior, or compatibility.

Check

  • Added malformed input cases to the existing url_decode regression test.
  • No core code was modified.
  • No .out file update is required because these are error assertion cases.

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@yifanwu-sys

Copy link
Copy Markdown
Author

Thanks for the reminder. I have clarified the PR description below.

What problem was fixed?

This PR does not change the implementation behavior of url_decode. It adds missing regression test coverage for malformed percent-encoding inputs.

The existing url_decode regression test mainly covered valid URL decoding cases, but it did not explicitly cover malformed inputs such as:

  • truncated percent sequences;
  • a bare percent sign;
  • invalid hex characters;
  • mixed valid and invalid percent-encoded strings.

Without these regression tests, the existing error behavior of url_decode could be changed accidentally in future updates.

How was it fixed?

I added 6 error-case tests to:

regression-test/suites/query_p0/sql_functions/string_functions/test_url_decode.groovy

The added cases include:

select url_decode('%2');
select url_decode('%');
select url_decode('hello%');
select url_decode('%GG');
select url_decode('%20%GG%41');
select url_decode('%%20');

Each case verifies that malformed percent-encoding raises the expected error:

Decode url failed

Which behaviors were modified?

No Doris runtime behavior was modified.

Before this PR:

  • url_decode already returned an error for malformed percent-encoding inputs.
  • However, these error cases were not covered by regression tests.

After this PR:

  • The same existing behavior is now covered by regression tests.
  • Future changes to url_decode can detect regressions in malformed input handling.

Why was it modified?

Malformed URL percent-encoding is a common edge case for URL decoding functions. Adding regression tests helps document and protect the expected error behavior.

Possible impact

This is a test-only change.

It does not affect:

  • Doris build behavior;
  • runtime behavior;
  • SQL execution logic;
  • storage behavior;
  • query execution;
  • compatibility.

New features

No new feature was added.

Refactoring

No code was refactored.

Optimization

No function was optimized. This PR only adds regression test coverage for existing url_decode error behavior.

Verification

This PR only adds constant SQL error assertion cases.

The added cases verify that malformed percent-encoding inputs raise:

Decode url failed

No core code was modified, and no .out file update is required because these are exception assertion cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants